<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>
        <li id = 'foo'>foo</li>
        <li id = 'bar'>bar</li>
        <li id = 'baz'>baz</li>
    </ul>
</body>
    <script src="js/jquery-3.7.1.js" type="text/javascript" charset="utf-8"></script>
    <script>
          var index =  $("li").index($('#bar'))

           console.log(index);
    </script>
</html>